package com.zh.mybatis.domain.student.mapper;

import com.zh.mybatis.domain.student.entity.StudentEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author ZH
 * @date 10:35 2021/9/1
 */
//会动态代理一个mapper实现类
@Mapper
public interface StudentMapper {

    @Select("SELECT count(*) FROM student")
    int count();

    StudentEntity findStudent(@Param("studentId") Long id);

    @ResultMap("fullStudentResultMapLazy")
    @Select("SELECT *FROM student s WHERE s.id = #{studentId}")
    StudentEntity findStudentLazy(@Param("studentId") Long id);

    @Select("SELECT * FROM student")
    List<StudentEntity> findAll();

    List<StudentEntity> findFullAll();

    @ResultMap("fullStudentResultMapLazy")
    @Select("SELECT *FROM student")
    List<StudentEntity> findFullAllLazy();

}
